package com.test.semaphore.exchanger;

import java.util.concurrent.Exchanger;

/**
 * @author:wesley
 */
public class ThreadB extends Thread{

    private Exchanger<String> exchanger;

    public ThreadB(Exchanger<String> exchanger) {
        this.exchanger = exchanger;
    }


    @Override
    public void run() {
        try {
            System.out.println("线程B获取线程A数据====" +exchanger.exchange("中国人B"));
            System.out.println("B end");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
